package com.nix.web.databases.service.word;

import com.nix.web.databases.CurdFactory;
import com.nix.web.databases.mapper.word.WordMapper;
import com.nix.web.databases.pojo.word.Word;
import com.nix.web.databases.pojo.word.WordError;
import com.nix.web.databases.service.iteratory.Iterator;
import com.nix.web.databases.service.iteratory.ObjectAggregate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 对单词的操作的基本实现
 * Create by zhangpe0312@qq.com on 2017/12/12.
 */
@Service
public abstract class WordService implements WordMapper {

    @Autowired
    private WordMapper wordMapper;

    /**
     * 用来批量添加单词的方位
     *
     * @param iterator 添加单词的迭代器
     * @param groupNumber 每组添加的单词个数 一半建议为 1000-3000
     */
    public abstract void batchAddWord(Iterator iterator, Integer groupNumber);

    /**
     *
     * @param word
     * @throws Exception 添加失败
     */
    public void addCategory(Word word) throws Exception{
        wordMapper.addCategory(word.getId(),word.getCategory().getId());
    }

    @Override
    public boolean add(Word word) throws Exception {

        return wordMapper.add(word);
    }

    @Override
    public boolean delete(Integer id) {
        return false;
    }

    @Override
    public boolean update(Word word) {
        return false;
    }

    @Override
    public Word select(Integer id) {
        return null;
    }
}
